﻿//********************************************************************************//
//创建日期：<创建日期，>
//创建作者：<朱大鹏>
//功能说明：全年井信息查询
//修改:郭登杰 at20170705
//********************************************************************************//
using BLL;
using BLL.Access;
using DevExpress.Web;
using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Class;
using System.Data.OleDb;
using System.Text.RegularExpressions;

namespace Web.Pages.QuShui.DiXiaS.ChaXunGL
{
    public partial class QuanNianJXXCX : BasePage
    {
        public class Conditions
        {
            public Conditions()
            {
                
            }
            public int y { get; set; }
            public int m { get; set; }
            public string huanxianbj { get; set; }
            public string xingzhengq { get; set; }
            public string laobh { get; set; }
            public string jinlx { get; set; }
            public string jinxz { get; set; }
            public string jinbj { get; set; }
            public string shuilianglb { get; set; }
            public string shuiliangtj { get; set; }
            public string shuiliang { get; set; }
            public string yhh { get; set; }
            public string yhm { get; set; }
            public string dizhi { get; set; }
            public string jinbh { get; set; }
            public string xkzh { get; set; }
            public string jindz { get; set; }
            public string qushuiyt { get; set; }
            public string hangyelx { get; set; }
            public string bumen { get; set; }
            public string liuyu { get; set; }
            public string shuiziyfq { get; set; }
            public string shuilifp { get; set; }
            public string shenjinsftj { get; set; }
            public string shenjinsf { get; set; }
            public string cengci { get; set; }
            public string xiaojinymtj1 { get; set; }
            public string xiaojinym1 { get; set; }
            public string xiaojinymtj2 { get; set; }
            public string xiaojinym2 { get; set; }
            public string huizonglx { get; set; }
        }
        #region 属性

        /// <summary>
        /// 保存结果集1
        /// </summary>
        private DataTable dtShenJingXX1
        {
            get
            {
                return ViewState["dtShenJingXX1"] as DataTable;
            }
            set
            {
                ViewState["dtShenJingXX1"] = value;
            }
        }
        private DataTable dtShenJingXX2_1
        {
            get
            {
                return ViewState["dtShenJingXX2_1"] as DataTable;
            }
            set
            {
                ViewState["dtShenJingXX2_1"] = value;
            }
        }
        private DataTable dtShenJingXX2_2
        {
            get
            {
                return ViewState["dtShenJingXX2_2"] as DataTable;
            }
            set
            {
                ViewState["dtShenJingXX2_2"] = value;
            }
        }
        private DataTable dtShenJingXX3
        {
            get
            {
                return ViewState["dtShenJingXX3"] as DataTable;
            }
            set
            {
                ViewState["dtShenJingXX3"] = value;
            }
        }

        private DataTable dtShenJingXX4
        {
            get
            {
                return ViewState["dtShenJingXX4"] as DataTable;
            }
            set
            {
                ViewState["dtShenJingXX4"] = value;
            }
        }
        #endregion

        #region 变量

        /// <summary>
        /// 数据访问操作类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();
        /// <summary>
        /// 行政区
        /// </summary>
        QS_JX_XINGZHENGQBLL XZQ = new QS_JX_XINGZHENGQBLL();
        /// <summary>
        /// 行业分类
        /// </summary>
        QS_JX_HANGYEFLXXBLL HYFL = new QS_JX_HANGYEFLXXBLL();
        /// <summary>
        /// 取水用途
        /// </summary>
        QS_JX_QUSHUIXXBLL QSYT = new QS_JX_QUSHUIXXBLL();
        /// <summary>
        /// 管理部门
        /// </summary>
        QS_JX_BUMENXXBLL GLBM = new QS_JX_BUMENXXBLL();
        /// <summary>
        /// 流域信息
        /// </summary>
        QS_JX_LIUYUXXBLL LYXX = new QS_JX_LIUYUXXBLL();
        /// <summary>
        /// 水利分片
        /// </summary>
        QS_JX_SHUILIFPXXBLL SLFP = new QS_JX_SHUILIFPXXBLL();
        /// <summary>
        /// 水资源分区
        /// </summary>
        QS_JX_SHUIZIYFQBLL SZYFQ = new QS_JX_SHUIZIYFQBLL();
        /// <summary>
        /// 井标记
        /// </summary>
        QS_JX_JINGBIAOJXXBLL JBJ = new QS_JX_JINGBIAOJXXBLL();
        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                InitData();
            }
            BindShenJingXX(false);
            BindShenJingNianXX(false);
            BindShenJingYueXX(false);
            BindYueHZ(false);
            //this.ScriptManager1.RegisterPostBackControl(this.btnActPerformExport);
        }




        /// <summary>
        /// 查询信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnChaXun_Click(object sender, EventArgs e)
        {

           // try
            //{
                int actindex = ASPxPageControl1.ActiveTabIndex;
                switch (actindex)
                {
                    case 0: BindShenJingXX(true);
                        break;
                    case 1: BindShenJingNianXX(true);
                        break;
                    case 2: BindShenJingYueXX(true);
                        break;
                    case 3: BindYueHZ(true);
                        break;
                };
            //}
            //catch (Exception ex)
            //{

            //}
        }

        #endregion

        #region 方法

        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            int wtype = BusinessTool.WType;
            ;
            gvShenJingXX.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            //水量年月
            string water_y_m = BusinessTool.GetSLYMorZWNY(1, wtype).ToString();


            //加载管理部门
            LoadGLBM();
            //加载行政区
            LoadXZQ();
            //加载业务员
            //LoadYWY();
            //加载取水用途
            LoadQSYT();
            //加载行业分类
            LoadHYFL();
        }



        /// <summary>
        /// 加载管理部门
        /// </summary>
        private void LoadGLBM()
        {
            PageTools.QSLoadCombox(this.cbmGuanLiBM, PageTools.eLoadType.管理部门QS, null, "");
            for (int i = DateTime.Now.Year; i > DateTime.Now.Year-10; i--)
            {
                cmbYear.Items.Add(i.ToString(), i.ToString());
            }

            for (int i = 1; i <= 12; i++)
            {
                cmbMonth.Items.Add(i.ToString(), i.ToString());
            }
            cmbMonth.Items.Add("全部",13);
            cmbYear.Value = BusinessTool.GetSLYMorZWNY(1, BusinessTool.WType) / 100;
            cmbMonth.Value = BusinessTool.GetSLYMorZWNY(1, BusinessTool.WType) % 100;

            PageTools.QSLoadCombox(cmbLiuYu, PageTools.eLoadType.流域QS, null, "");
            PageTools.QSLoadCombox(this.cmbShuiZiY, PageTools.eLoadType.水资源分区QS, null, "");
            PageTools.QSLoadCombox(this.cmbShuiLiFP, PageTools.eLoadType.水利分片QS, null, "");
        }

        /// <summary>
        /// 加载行政区
        /// </summary>
        private void LoadXZQ()
        {
            PageTools.QSLoadCombox(this.cmbXingZhengQ, PageTools.eLoadType.行政区QS, null, "");
        }




        /// <summary>
        /// 加载 取水用途
        /// </summary>
        private void LoadQSYT()
        {
            PageTools.QSLoadCombox(this.cmbQuShuiYT, PageTools.eLoadType.取水用途QS, null, "");
        }
        /// <summary>
        /// 加载行业分类
        /// </summary>
        private void LoadHYFL()
        {
            PageTools.QSLoadCombox(this.cmbHangYeLX, PageTools.eLoadType.行业分类QS, null, "");
        }

        private Conditions getConditions()
        {
            Conditions conditions = new Conditions();
            conditions.y= Convert.ToInt32(cmbYear.Value);
            conditions.m= Convert.ToInt32(cmbMonth.Value);
            conditions.huanxianbj= cmbHuanNeiHW.SelectedIndex <= 0 ? null : cmbHuanNeiHW.Value.ToString().Trim();
            conditions.xingzhengq= cmbXingZhengQ.SelectedIndex <= 0 ? null : Convert.ToString(cmbXingZhengQ.Value);
            conditions.laobh= string.IsNullOrEmpty(txtJingHao.Text) ? null : txtJingHao.Text;
            conditions.jinlx= cmbJLX.SelectedIndex <= 0 ? null : Convert.ToString(cmbJLX.Value);
            conditions.jinxz= cmbJXZ.SelectedIndex <= 0 ? null : Convert.ToString(cmbJXZ.Value);
            conditions.jinbj= cmbJBJ.SelectedIndex <= 0 ? null : Convert.ToString(cmbJBJ.Value);
            conditions.shuilianglb= cmbTiaoJian.SelectedIndex <= 0 ? null : cmbTiaoJian.Value.ToString();
            conditions.shuiliangtj= cmbTJ.SelectedIndex <= 0 ? null : cmbTJ.Value.ToString();
            conditions.shuiliang= string.IsNullOrEmpty(txtShuiLiangTJ.Text) ? null : txtShuiLiangTJ.Text;

            conditions.yhh= string.IsNullOrEmpty(txtYongHuH.Text) ? null : txtYongHuH.Text;
            conditions.yhm= string.IsNullOrEmpty(txtYongHuM.Text) ? null : txtYongHuM.Text;
            conditions.dizhi= string.IsNullOrEmpty(txtYongHuDZ.Text) ? null : txtYongHuDZ.Text;
            conditions.jinbh= string.IsNullOrEmpty(txtJingBianH.Text) ? null : txtJingBianH.Text;
            conditions.xkzh= string.IsNullOrEmpty(txtXuKeZH.Text) ? null : txtXuKeZH.Text;
            conditions.jindz= string.IsNullOrEmpty(txtQuShuiDZ.Text) ? null : txtQuShuiDZ.Text;
            conditions.qushuiyt= cmbQuShuiYT.SelectedIndex <= 0 ? null : cmbQuShuiYT.Value.ToString();
            conditions.hangyelx= cmbHangYeLX.SelectedIndex <= 0 ? null : cmbHangYeLX.Value.ToString();
            conditions.bumen= cbmGuanLiBM.SelectedIndex <= 0 ? null : cbmGuanLiBM.Value.ToString();
            conditions.liuyu= cmbLiuYu.SelectedIndex <= 0 ? null : Convert.ToString(cmbLiuYu.Value);
            conditions.shuiziyfq= cmbShuiZiY.SelectedIndex <= 0 ? null : Convert.ToString(cmbShuiZiY.Value);
            conditions.shuilifp= cmbShuiLiFP.SelectedIndex <= 0 ? null : Convert.ToString(cmbShuiLiFP.Value);
            conditions.shenjinsftj= cmbShenJingSFTJ.SelectedIndex <= 0 ? null : cmbShenJingSFTJ.Value.ToString();
            conditions.shenjinsf= string.IsNullOrEmpty(txtShenJingSF.Text) ? null : txtShenJingSF.Text;
            conditions.cengci= cmbCengCi.SelectedIndex <= 0 ? null : cmbCengCi.Value.ToString();
            conditions.xiaojinymtj1= cmbXiaoJingTJ1.SelectedIndex <= 0 ? null : cmbXiaoJingTJ1.Value.ToString();
            conditions.xiaojinym1= string.IsNullOrEmpty(txtXiaoJingTJ1.Text) ? null : txtXiaoJingTJ1.Text;
            conditions.xiaojinymtj2= cmbXiaoJingTJ2.SelectedIndex <= 0 ? null : cmbXiaoJingTJ2.Value.ToString();
            conditions.xiaojinym2= string.IsNullOrEmpty(txtXiaoJingTJ2.Text) ? null : txtXiaoJingTJ2.Text;

            conditions.huizonglx= cmbHuiZongLX.SelectedIndex <= 0 ? null : cmbHuiZongLX.Value.ToString();
            return conditions;
        }

        /// <summary>
        /// 深井信息查询
        /// </summary>
        private DataTable BindShenJingXX(bool reget)
        {
            Conditions cs = this.getConditions();
            if (reget)
            {
                this.dtShenJingXX1 = new SpHelper().P_QS_CX_SHENJINXXCX(null, cs.y,
                                                                       cs.m,
                                                                       cs.huanxianbj,
                                                                       cs.xingzhengq,
                                                                       cs.laobh,
                                                                       cs.jinlx,
                                                                       cs.jinxz,
                                                                       cs.jinbj,
                                                                       cs.shuilianglb,
                                                                       cs.shuiliangtj,
                                                                       cs.shuiliang == null ? null : (decimal?)Convert.ToDecimal(cs.shuiliang),
                                                                       cs.yhh,
                                                                       cs.yhm,
                                                                       cs.dizhi,
                                                                       cs.jinbh,
                                                                       cs.xkzh,
                                                                       cs.jindz,
                                                                       cs.qushuiyt,
                                                                       cs.hangyelx,
                                                                       cs.bumen,
                                                                       cs.liuyu,
                                                                       cs.shuiziyfq,
                                                                       cs.shuilifp,
                                                                       cs.shenjinsftj,
                                                                       cs.shenjinsf == null ? null : (decimal?)Convert.ToDecimal(cs.shenjinsf),
                                                                       cs.cengci,
                                                                       cs.xiaojinymtj1,
                                                                       cs.xiaojinym1,
                                                                       cs.xiaojinymtj2,
                                                                       cs.xiaojinym2,
                                                                       null
                                                                       ).Tables[0];
            }
            this.gvShenJingXX.DataSource = this.dtShenJingXX1;
            this.gvShenJingXX.DataBind();
            if (this.dtShenJingXX1 != null && this.dtShenJingXX1.Rows.Count > 0)
            {
                this.zjl.Text = "共" + this.dtShenJingXX1.Rows.Count.ToString() + "条记录";
                this.gvShenJingXX.FocusedRowIndex = -1;
                this.gvShenJingXX.FocusedRowIndex = 0;
            }
            else
            {
                this.zjl.Text = "共0条记录";
            }
            return this.dtShenJingXX1;
        }
        
        /// <summary>
        /// 全年用水情况
        /// </summary>
        private DataTable BindShenJingNianXX(bool reget)
        {
            Conditions cs=this.getConditions();
            if (reget)
            {
                this.dtShenJingXX2_1 = SearchSpHelper.P_QS_CX_SHENJINXXCX_SL(0,null,cs.y,
                                                                       13,
                                                                       cs.huanxianbj,
                                                                       cs.xingzhengq,
                                                                       cs.laobh,
                                                                       cs.jinlx,
                                                                       cs.jinxz,
                                                                       cs.jinbj,
                                                                       cs.shuilianglb,
                                                                       cs.shuiliangtj,
                                                                       cs.shuiliang == null ? null : (decimal?)Convert.ToDecimal(cs.shuiliang),
                                                                       cs.yhh,
                                                                       cs.yhm,
                                                                       cs.dizhi,
                                                                       cs.jinbh,
                                                                       cs.xkzh,
                                                                       cs.jindz,
                                                                       cs.qushuiyt,
                                                                       cs.hangyelx,
                                                                       cs.bumen,
                                                                       cs.liuyu,
                                                                       cs.shuiziyfq,
                                                                       cs.shuilifp,
                                                                       cs.shenjinsftj,
                                                                       cs.shenjinsf == null ? null : (decimal?)Convert.ToDecimal(cs.shenjinsf),
                                                                       cs.cengci,
                                                                       cs.xiaojinymtj1,
                                                                       cs.xiaojinym1,
                                                                       cs.xiaojinymtj2,
                                                                       cs.xiaojinym2
                                                                       ).Tables[0];
            }
            this.gvGridTab2.DataSource = this.dtShenJingXX2_1;
            this.gvGridTab2.DataBind();
            if (this.dtShenJingXX2_1 != null && this.dtShenJingXX2_1.Rows.Count > 0)
            {
                this.tab2ls1Count.Text = "共" + (this.dtShenJingXX2_1.Rows.Count - 1).ToString() + "条记录";
                this.gvGridTab2.FocusedRowIndex = -1;
                this.gvGridTab2.FocusedRowIndex = 0;
            }
            else
            {
                this.tab2ls1Count.Text = "共0条记录";
            }
            return this.dtShenJingXX2_1;
        }

        /// <summary>
        /// 月用水情况
        /// </summary>
        private DataTable BindShenJingYueXX(bool reget)
        {
            Conditions cs=this.getConditions();
            if (reget)
            {
                this.dtShenJingXX3 = SearchSpHelper.P_QS_CX_SHENJINXXCX_SL(0,null, cs.y,
                                                                        cs.m,
                                                                       cs.huanxianbj,
                                                                       cs.xingzhengq,
                                                                       cs.laobh,
                                                                       cs.jinlx,
                                                                       cs.jinxz,
                                                                       cs.jinbj,
                                                                       cs.shuilianglb,
                                                                       cs.shuiliangtj,
                                                                       cs.shuiliang == null ? null : (decimal?)Convert.ToDecimal(cs.shuiliang),
                                                                       cs.yhh,
                                                                       cs.yhm,
                                                                       cs.dizhi,
                                                                       cs.jinbh,
                                                                       cs.xkzh,
                                                                       cs.jindz,
                                                                       cs.qushuiyt,
                                                                       cs.hangyelx,
                                                                       cs.bumen,
                                                                       cs.liuyu,
                                                                       cs.shuiziyfq,
                                                                       cs.shuilifp,
                                                                       cs.shenjinsftj,
                                                                       cs.shenjinsf == null ? null : (decimal?)Convert.ToDecimal(cs.shenjinsf),
                                                                       cs.cengci,
                                                                       cs.xiaojinymtj1,
                                                                       cs.xiaojinym1,
                                                                       cs.xiaojinymtj2,
                                                                       cs.xiaojinym2
                                                                       ).Tables[0];
            }
            this.gvGridTab3.DataSource = this.dtShenJingXX3;
            this.gvGridTab3.DataBind();
            if (this.dtShenJingXX3 != null && this.dtShenJingXX3.Rows.Count > 0)
            {
                this.tab3ls1Count.Text = "共" + (this.dtShenJingXX3.Rows.Count - 1).ToString() + "条记录";
            }
            else
            {
                this.tab3ls1Count.Text = "共0条记录";
            }
            return this.dtShenJingXX3;
        }
        /// <summary>
        /// 深井月用水情况汇总
        /// </summary>
        private DataTable BindYueHZ(bool reget)
        {
            Conditions cs = this.getConditions();
            int hzlx= Convert.ToInt32(cmbHuiZongLX.Value);
            if (reget)
            {
                this.dtShenJingXX4 = SearchSpHelper.P_QS_CX_SHENJINXXCX_SL(0,hzlx, cs.y,
                                                                        cs.m,
                                                                       cs.huanxianbj,
                                                                       cs.xingzhengq,
                                                                       cs.laobh,
                                                                       cs.jinlx,
                                                                       cs.jinxz,
                                                                       cs.jinbj,
                                                                       cs.shuilianglb,
                                                                       cs.shuiliangtj,
                                                                       cs.shuiliang == null ? null : (decimal?)Convert.ToDecimal(cs.shuiliang),
                                                                       cs.yhh,
                                                                       cs.yhm,
                                                                       cs.dizhi,
                                                                       cs.jinbh,
                                                                       cs.xkzh,
                                                                       cs.jindz,
                                                                       cs.qushuiyt,
                                                                       cs.hangyelx,
                                                                       cs.bumen,
                                                                       cs.liuyu,
                                                                       cs.shuiziyfq,
                                                                       cs.shuilifp,
                                                                       cs.shenjinsftj,
                                                                       cs.shenjinsf == null ? null : (decimal?)Convert.ToDecimal(cs.shenjinsf),
                                                                       cs.cengci,
                                                                       cs.xiaojinymtj1,
                                                                       cs.xiaojinym1,
                                                                       cs.xiaojinymtj2,
                                                                       cs.xiaojinym2
                                                                       ).Tables[0];
            }
            this.gvGridTab4.Columns[1].Caption = hzlx==1?"行政区":hzlx==2?"环内环外":hzlx==3?"取水用途":hzlx==4?"行业分类":hzlx==5?"井类型":hzlx==6?"井状态":hzlx==7?"井标记"
                :hzlx==8?"层次":hzlx==9?"主管部门":hzlx==10?"流域":hzlx==11?"水资源分区":hzlx==12?"水利分片":"";
            this.gvGridTab4.DataSource = this.dtShenJingXX4;
            this.gvGridTab4.DataBind();
            if (this.dtShenJingXX4 != null && this.dtShenJingXX4.Rows.Count > 0)
            {
                this.tab4ls1Count.Text = "共" + (this.dtShenJingXX4.Rows.Count - 1).ToString() + "条记录";
            }
            else
            {
                this.tab4ls1Count.Text = "共0条记录";
            }
            return this.dtShenJingXX4;
        }
        
      

        /// <summary>
        /// 前台表格行改变事件回调方法
        /// </summary>
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            CallbackResult cr = new CallbackResult(e.Parameter);
            int id = this.hdCollection.Contains("ID") ? Convert.ToInt32(this.hdCollection.Get("ID")) : -1;
            if (e.Parameter == "setinfo")
            {
                string msg = "";
                if (this.dtShenJingXX1 != null && this.dtShenJingXX1.Rows.Count > 0)
                {
                    int y = Convert.ToInt32(cmbYear.Value);
                    int m = Convert.ToInt32(cmbMonth.Value);
                    DataTable dt_temp = _SpHelper.P_QS_CX_SHENJINXXCX(id.ToString(), y, m, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
                                                                    null, null, null,null).Tables[0];
                    cr.IsSuccess = true;
                    cr.AddValue(dt_temp.Rows[0]["S_YONGHUH"].ToString(),
                        dt_temp.Rows[0]["S_YONGHUM"].ToString(),
                         dt_temp.Rows[0]["HUANXIANBJ"].ToString(),
                        dt_temp.Rows[0]["S_JINGBH"].ToString(),
                        dt_temp.Rows[0]["S_DIZHI"].ToString(),
                         dt_temp.Rows[0]["S_XINGZHENGQM"].ToString(),
                        dt_temp.Rows[0]["JINLX"].ToString(),
                         dt_temp.Rows[0]["JINXZ"].ToString(),
                         dt_temp.Rows[0]["JINBJ"].ToString(),
                        dt_temp.Rows[0]["S_LIUYUMC"].ToString(),
                        dt_temp.Rows[0]["S_YEWUYMC"].ToString(),
                        dt_temp.Rows[0]["S_BUMENMC"].ToString(),
                         dt_temp.Rows[0]["S_SHUIZIYMC"].ToString(),
                        dt_temp.Rows[0]["I_CENG"].ToString(),
                        dt_temp.Rows[0]["S_SHENGDU"].ToString(),
                        dt_temp.Rows[0]["S_QUSHUIMC"].ToString(),
                        dt_temp.Rows[0]["S_SHUILIFPMC"].ToString(),
                        dt_temp.Rows[0]["I_KONGJING"].ToString(),
                        dt_temp.Rows[0]["S_FENLEIMC"].ToString(),
                        dt_temp.Rows[0]["S_BEIZHU"].ToString(),
                         dt_temp.Rows[0]["S_LAOBIANH"].ToString(),
                        dt_temp.Rows[0]["BIAOSHU"].ToString(),
                        dt_temp.Rows[0]["S_XUKEZHENGBH"].ToString());
                }
                e.Result = cr.ToString();
            }
            else if (e.Parameter == "export")
            {
                int actindex = ASPxPageControl1.ActiveTabIndex;
                if (actindex == 0)
                {
                    if (this.dtShenJingXX1 == null || this.dtShenJingXX1.Rows.Count == 0)
                    {
                        cr.IsAlertMsg = true;
                        cr.Msg = "没有可供导出的数据";
                        e.Result = cr.ToString();
                    }
                    else
                    {
                        cr.IsSuccess = true;
                        e.Result = cr.ToString();
                    }
                }
                else if (actindex == 1)
                {
                    if (this.dtShenJingXX2_1 == null || this.dtShenJingXX2_1.Rows.Count == 0)
                    {
                        cr.IsAlertMsg = true;
                        cr.Msg = "没有可供导出的数据";
                        e.Result = cr.ToString();
                    }
                    else
                    {
                        cr.IsSuccess = true;
                        e.Result = cr.ToString();
                    }
                }
                if (actindex == 2)
                {
                    if (this.dtShenJingXX3 == null || this.dtShenJingXX3.Rows.Count == 0)
                    {
                        cr.IsAlertMsg = true;
                        cr.Msg = "没有可供导出的数据";
                        e.Result = cr.ToString();
                    }
                    else
                    {
                        cr.IsSuccess = true;
                        e.Result = cr.ToString();
                    }
                }
                if (actindex == 3)
                {
                    if (this.dtShenJingXX4 == null || this.dtShenJingXX4.Rows.Count == 0)
                    {
                        cr.IsAlertMsg = true;
                        cr.Msg = "没有可供导出的数据";
                        e.Result = cr.ToString();
                    }
                    else
                    {
                        cr.IsSuccess = true;
                        e.Result = cr.ToString();
                    }
                }
            }
        }
        /*
        protected void btnActPerformExport_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            int actindex = ASPxPageControl1.ActiveTabIndex;
            string filename = "";
            switch (actindex)
            {
                case 0: dt = BindShenJingXX(false);
                    filename = "深井信息.xls";
                    break;
                case 1: dt = BindShenJingNianXX(false);
                    filename = "深井全年用水情况.xls";
                    break;
                case 2: dt = BindShenJingYueXX(false);
                    filename = "深井" + Convert.ToString(this.cmbYear.Text) + "年" + this.cmbMonth.Text != "13" ? Convert.ToString(this.cmbMonth.Text) : "全年" + "月用水情况.xls";
                    break;
                case 3: dt = BindYueHZ(false);
                    filename = "深井" + Convert.ToString(this.cmbYear.Text) + "年" + this.cmbMonth.Text!="13"?Convert.ToString(this.cmbMonth.Text):"全年" + "用水按" + this.cmbHuiZongLX.Text + "汇总.xls";
                    break;
            };
            if (dt != null && dt.Rows.Count > 0)
            {
                PageTools.CreateExcel2(dt, filename);
            }
        }
        */
        #endregion



        protected void gvGrid2Tab2_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            string jinbh = e.Parameters;
            Conditions cs = this.getConditions();
            DataTable dt = SearchSpHelper.P_QS_CX_SHENJINXXCX_SL(1, null, cs.y,
                                                                       13,
                                                                       cs.huanxianbj,
                                                                       cs.xingzhengq,
                                                                       cs.laobh,
                                                                       cs.jinlx,
                                                                       cs.jinxz,
                                                                       cs.jinbj,
                                                                       cs.shuilianglb,
                                                                       cs.shuiliangtj,
                                                                       cs.shuiliang == null ? null : (decimal?)Convert.ToDecimal(cs.shuiliang),
                                                                       cs.yhh,
                                                                       cs.yhm,
                                                                       cs.dizhi,
                                                                       string.IsNullOrEmpty(jinbh.Trim()) ? null : jinbh,
                                                                       cs.xkzh,
                                                                       cs.jindz,
                                                                       cs.qushuiyt,
                                                                       cs.hangyelx,
                                                                       cs.bumen,
                                                                       cs.liuyu,
                                                                       cs.shuiziyfq,
                                                                       cs.shuilifp,
                                                                       cs.shenjinsftj,
                                                                       cs.shenjinsf == null ? null : (decimal?)Convert.ToDecimal(cs.shenjinsf),
                                                                       cs.cengci,
                                                                       cs.xiaojinymtj1,
                                                                       cs.xiaojinym1,
                                                                       cs.xiaojinymtj2,
                                                                       cs.xiaojinym2
                                                                       ).Tables[0];
            gvGrid2Tab2.DataSource = dt; 
            //gvGrid2Tab2.DataSource = SearchSpHelper.P_QS_CX_SHENJINXXCX_SL(1, Convert.ToInt32(this.cmbYear.Value), 13, null, null, null, null, null, null, null,
            //    null, null, null, null, null, string.IsNullOrEmpty(jinbh.Trim())?null:jinbh, null,null, null, null, null, null, null, null,null, null, null, null, null, null, null);
            gvGrid2Tab2.DataBind();
        }
        
        protected void btnExport_Click(object sender, EventArgs e)
        {
            int index = ASPxPageControl1.ActiveTabIndex;
            string sName = "";
            if (index == 0)
            {
                ASPxGridViewExporter1.GridViewID = "gvShenJingXX";
                sName = "深井信息";
                gvShenJingXX.Settings.ShowFooter = false;
                if (this.dtShenJingXX1 != null)
                {
                    for (int i = 0; i < this.dtShenJingXX1.Rows.Count; i++)
                    {
                        DataRow row = this.dtShenJingXX1.Rows[i];
                        for (int j = 0; j < this.dtShenJingXX1.Columns.Count; j++)
                        {
                            if (row[j].GetType().Equals(typeof(string)) && Regex.IsMatch(row[j].ToString(), @"^[+-]?\d*$"))
                            {
                                row[j] = "\r" + row[j];
                            }
                        }
                    }
                }
            }
            else if (index == 1)
            {
                ASPxGridViewExporter1.GridViewID = "gvGridTab2";
                sName = "深井全年用水情况";
                gvGridTab2.Settings.ShowFooter = false;
                if (this.dtShenJingXX2_1 != null)
                {
                    for (int i = 0; i < this.dtShenJingXX2_1.Rows.Count; i++)
                    {
                        DataRow row = this.dtShenJingXX2_1.Rows[i];
                        for (int j = 0; j < this.dtShenJingXX2_1.Columns.Count; j++)
                        {
                            if (row[j].GetType().Equals(typeof(string)) && Regex.IsMatch(row[j].ToString(), @"^[+-]?\d*$"))
                            {
                                row[j] = "\r" + row[j];
                            }
                        }
                    }
                }
            }
            else if (index == 2)
            {
                ASPxGridViewExporter1.GridViewID = "gvGridTab3";
                sName = "深井月用水情况";
                gvGridTab3.Settings.ShowFooter = false;
                if (this.dtShenJingXX3 != null)
                {
                    for (int i = 0; i < this.dtShenJingXX3.Rows.Count; i++)
                    {
                        DataRow row = this.dtShenJingXX3.Rows[i];
                        for (int j = 0; j < this.dtShenJingXX3.Columns.Count; j++)
                        {
                            if (row[j].GetType().Equals(typeof(string)) && Regex.IsMatch(row[j].ToString(), @"^[+-]?\d*$"))
                            {
                                row[j] = "\r" + row[j];
                            }
                        }
                    }
                }
            }
            else if (index == 3)
            {
                ASPxGridViewExporter1.GridViewID = "gvGridTab4";
                sName = "深井月用水汇总";
                gvGridTab4.Settings.ShowFooter = false;
                if (this.dtShenJingXX4 != null)
                {
                    for (int i = 0; i < this.dtShenJingXX4.Rows.Count; i++)
                    {
                        DataRow row = this.dtShenJingXX4.Rows[i];
                        for (int j = 0; j < this.dtShenJingXX4.Columns.Count; j++)
                        {
                            if (row[j].GetType().Equals(typeof(string)) && Regex.IsMatch(row[j].ToString(), @"^[+-]?\d*$"))
                            {
                                row[j] = "\r" + row[j];
                            }
                        }
                    }
                }
            }

            ASPxGridViewExporter1.WriteXlsToResponse(sName);

        }
        
    }
}